package com.haidechizi.fastadmin.modules.job.controller;

import com.haidechizi.fastadmin.common.page.PageDto;
import com.haidechizi.fastadmin.common.utils.PageInfo;
import com.haidechizi.fastadmin.common.utils.Response;
import com.haidechizi.fastadmin.modules.job.entity.ScheduleJobLog;
import com.haidechizi.fastadmin.modules.job.service.ScheduleJobLogService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 定时任务日志
 */
@RestController
@RequestMapping("/sys/scheduleLog")
public class ScheduleJobLogController {
    @Autowired
    private ScheduleJobLogService scheduleJobLogService;

    /**
     * 定时任务日志列表
     */
    @RequestMapping("/list")
    @RequiresPermissions("sys:schedule:log")
    public Response list(PageDto pageDto, ScheduleJobLog scheduleJobLog) {
        PageInfo page = scheduleJobLogService.queryPage(pageDto, scheduleJobLog);

        return Response.ok().put("page", page);
    }

    /**
     * 定时任务日志信息
     */
    @RequestMapping("/info/{logId}")
    public Response info(@PathVariable("logId") Long logId) {
        ScheduleJobLog log = scheduleJobLogService.selectById(logId);

        return Response.ok().put("log", log);
    }
}
